﻿<Page
    x:Class="CoachingOrganizer.WinPhone.Pages.GoalPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CoachingOrganizer.WinPhone.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sel="using:CoachingOrganizer.WinPhone.Selectors"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <sel:ToolsSelector x:Key="toolsSelector"/>
    </Page.Resources>
    <Grid x:Name="LayoutRoot">

        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Title Panel -->
        <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <TextBlock x:Uid="ApplicationTitle" Text="" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,12,0,0"/>
            <TextBlock Text="{Binding PageTitle}" Margin="0,-6.5,0,26.5" Style="{ThemeResource HeaderTextBlockStyle}" CharacterSpacing="{ThemeResource PivotHeaderItemCharacterSpacing}"/>
        </StackPanel>

        <!--TODO: Content should be placed within the following grid-->
        <Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,9.5,19,0">
            <FlipView SelectedIndex="{Binding CurrentTabIndex}">
                <FlipViewItem>
                    <TextBox Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap" MaxHeight="200"/>
                </FlipViewItem>
                <FlipViewItem>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <ListView Grid.ColumnSpan="2" ItemsSource="{Binding Tools}" ItemTemplateSelector="{StaticResource toolsSelector}">
                            <ListView.Resources>
                                <DataTemplate x:Key="moodLevelTemplate">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <DatePicker Grid.Column="1" Date="{Binding StartDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                        <DatePicker Grid.Column="2" Date="{Binding FinishDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                        <TimePicker Grid.Column="3" Time="{Binding Period, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                        <StackPanel Grid.Column="4">
                                            <Button x:Uid="Save" Command="{Binding SaveCommand}"/>
                                            <Button x:Uid="Remove" Command="{Binding RemoveCommand}"/>
                                            <Button x:Uid="Details" Command="{Binding GoDetailsCommand}"/>
                                        </StackPanel>
                                    </Grid>
                                </DataTemplate>
                                <DataTemplate x:Key="emotionsPackTemplate">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <TextBox/>
                                        <StackPanel Grid.Column="1">
                                            <Button x:Uid="Save" Command="{Binding SaveCommand}"/>
                                            <Button x:Uid="Remove" Command="{Binding RemoveCommand}"/>
                                            <Button x:Uid="Details" Command="{Binding GoDetailsCommand}"/>
                                        </StackPanel>
                                    </Grid>
                                </DataTemplate>
                                <DataTemplate x:Key="moneyCalculationTemplate">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <DatePicker Date="{Binding StartDate}"/>
                                        <DatePicker Grid.Column="1" Date="{Binding FinishDate}"/>
                                        <StackPanel Grid.Column="2">
                                            <Button x:Uid="Save" Command="{Binding SaveCommand}"/>
                                            <Button x:Uid="Remove" Command="{Binding RemoveCommand}"/>
                                            <Button x:Uid="Details" Command="{Binding GoDetailsCommand}"/>
                                        </StackPanel>
                                    </Grid>
                                </DataTemplate>
                            </ListView.Resources>
                        </ListView>
                        <ComboBox ItemsSource="{Binding ToolsList}" SelectedIndex="{Binding SelectedToolIndex, Mode=TwoWay}" Grid.Row="1"/>
                        <Button x:Uid="AddTool" Command="{Binding AddNewToolCommand}" Grid.Row="1" Grid.Column="1"/>
                    </Grid>
                </FlipViewItem>
            </FlipView>
        </Grid>
    </Grid>
</Page>
